<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      body {
        white-space: pre-line;
      }
    </style>
  </head>
  <body>
    <script>
      //1. 循环打印1-10 ( 包含1包含10 )

      for (var i = 1; i <= 10; i++) {
        document.write(i + "\t");
      }
      document.write("\n");
      // 2. 循环打印1-10 ( 之间的偶数)
      for (var i = 0; i <= 10; i++) {
        if (i % 2 == 0) {
          document.write(i + "\t");
        }
      }
      document.write("\n");
      // 3. 使用循环完成1到5的求和
      for (var i = 0, sum = 0; i <= 5; i++) {
        sum += i;
      }
      document.write("1到5的求和=" + sum + "\t");
      document.write("\n");
      // 4. 使用循环完成1到5的累乘
      for (var i = 1, sum = 1; i <= 5; i++) {
        sum *= i;
      }
      document.write("1到5的累乘=" + sum + "\t");
      document.write("\n");
      // 5. 反转字符串'abcdefg' 反转结果为 'gfedcba'
      var str = "abcdefg";
      var newstr = "";
      for (var i = str.length - 1; i >= 0; i--) {
        newstr += str[i];
      }
      document.write(newstr);
    </script>
  </body>
</html>
